<template>
    <div class="design-item">
        <div class="design-item-controller">
            <div class="design-item-controller-handle">
                <div class="design-component-store-preview ">
                    <div class="store-preview-main">
                        <i class="fa fa-home"></i>
                        <span class="store-preview-title">店铺名称</span>
                        <span class="store-preview-text">{{actionText}}<i class="fa fa-angle-right icon-arrow"></i>
                        </span>
                    </div>
                </div>
            </div>
            <slot name="menu"></slot>
        </div>
        <div class="design-item-editor" v-show="show && !showAddMenuGroup">
            <div>
                <div class="design-item-editor-title">进入店铺</div>
                <div class="editor-group">
                    <div class="editor-group-label">文本：</div>
                    <div class="editor-group-control">
                        <div class="input-wrap">
                            <input v-model="actionText" maxlength="7">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <slot name="addMenuGroup" v-if="showAddMenuGroup"></slot>
    </div>
</template>
<script>

    /**
     * 默认的数据格式
     */
    var defaultDataFormat = {
        // 文案
        actionText: '',
        // 背景颜色
        type: 'store'
    }
    export default {
        name: "nc-design-item-store",
        otherInfo: {
            title: '进入店铺',
            type: 'store',
            group: 2,
            max: 0
        },
        //外部传入参数
        props: {
            show: {
                type: Boolean,
                default: false
            },
            options: {
                type: Object,
                default: null
            },
            cid: {
                type: Number
            },
            showAddMenuGroup: {
                type: Boolean,
                default: false
            }
        },
        /*
         * 自身数据,一定要一个function
         */
        data() {
            let data = !Nc.isEmpty(this.options) ? {
                actionText: this.options.actionText
            } : ($.extend(true, {}, defaultDataFormat))

            let customData = {}
            return $.extend({}, data, customData)
        },
        methods: {
            /**
             * 获取当前数据
             */
            getCurrentData () {
                return {
                    actionText: this.actionText,
                    type: this.type
                }
            }
        }
    };
</script>